package healthwatcher.frascati.storage;

import java.io.File;
import java.util.Properties;

import org.jclouds.ContextBuilder;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.InputStreamMap;
import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;

import healthwatcher.storage.IStorage;

public class StorageHP implements IStorage {

	@Override
	public void storePhoto(String code, File file) {
		Properties props=new Properties();
		props.setProperty(KeystoneProperties.CREDENTIAL_TYPE, CredentialTypes.API_ACCESS_KEY_CREDENTIALS);
		
		BlobStoreContext context=ContextBuilder.newBuilder("hpcloud-objectstorage").
				credentials("andregustavoo-tenant1:WU7UC9PHMZR5HCJNX8TA", "tbVCFfpoVTQjRp7YjjJwz0C5lOpI0wrOg0HYptH1").overrides(props).build(BlobStoreContext.class);
		
		
		//BlobStoreContext context = new BlobStoreContextFactory().createContext("hpcloud-objectstorage", "WU7UC9PHMZR5HCJNX8TA", "tbVCFfpoVTQjRp7YjjJwz0C5lOpI0wrOg0HYptH1");
		
		InputStreamMap input= context.createInputStreamMap("hw");
		
		
		input.putFile(code+".jpg",file);
		
		context.close();
		
		
	}

}
